package top.blackr.folivora.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author BlackR
 */
@Data
@Component
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "folivora")
public class ApplicationProperties {

    /**
     * 微信支付
     */
    private WxPay wxPay;
    /**
     * 支付宝支付
     */
    private AliPay aliPay;
    /**
     * 安全认证
     */
    private Security security;


    @Data
    @Component
    @ConfigurationProperties(prefix = "folivora.security")
    public static class Security {
        /**
         * 三方登录路径
         */
        private String thirdLoginUrl = "/thirdLogin";
        /**
         * token失效时间，单位秒
         */
        private Long tokenExpireTime;
        /**
         * 不需要认证路径
         */
        private List<String> ignoredUrls;
        private String key = "folivora";
    }

    @Data
    @Component
    @ConfigurationProperties(prefix = "folivora.wx-pay")
    public static class WxPay {
        /**
         * 是否测试（实际支付1分钱）
         */
        private Boolean isTest;
        /**
         * 小程序appId
         */
        private String appId;
        /**
         * 小程序appSecret
         */
        private String appSecret;
        /**
         * 商户id
         */
        private String mchId;
        /**
         * api key
         */
        private String partnerKey;
        /**
         * 支付回调地址，外网可访问的https
         */
        private String notifyUrl;
        /**
         * 过期时间：单位秒
         */
        private Integer timeExpire;
        /**
         * 平台证书序列号
         */
        private String mchSerialNo;
        /**
         * 平台证书路径
         */
        private String wechatPayCertificateUrl;
        /**
         * API V3密钥
         */
        private String apiV3Key;

        private String mpAppId = "wx2f21074846645e7b";

        private String mpAppSecret = "8cbef3ca1f5e17f4968a63f3d3c4c208";
    }

    @Data
    @Component
    @ConfigurationProperties(prefix = "folivora.ali-pay")
    public static class AliPay {
        /**
         * 帐号的应用私钥
         */
        private String privateKey;
        /**
         * 支付宝网关
         */
        private String serverUrl;
        /**
         * 支付宝网关
         */
        private String localFileUrl;
        /**
         * 支付回调地址，外网可访问的https
         */
        private String notifyUrl;
        /**
         * 支付宝应用APPID
         */
        private String appId;
        /**
         * 支付宝用户ID
         */
        private String sellerId;

    }
}